/**
 * Check Admin Login
 * Author  : Jun Li
 * Version : 1.0.5
 * Email   : lijun@jpxx.org
 * Homepage: http://www.jpxx.org
 */
function checkLogin(o){
    var username = document.manage.username.value;
    var password = document.manage.password.value;
    var code = document.manage.code.value;
    if(o){
        if(username==""){
            setHtml(o,"\u7528\u6237\u540d\u4e0d\u80fd\u7a7a\uff01");
            document.manage.username.focus();
        }
        else if(password==""){
            setHtml(o,"\u5bc6\u7801\u4e0d\u80fd\u7a7a\uff01");
            document.manage.password.focus();
        }
        else if(code==""){
            setHtml(o,"\u9a8c\u8bc1\u7801\u4e0d\u80fd\u7a7a\uff01");
            document.manage.code.focus();
        }
        else{
            admin_login.checkLogin(
                username,
                password,
                code,
                function(data){
                    if(data==-5){
                        setHtml(o,"验证码错误\uff01");
                        document.manage.code.value="";
                        document.manage.code.focus();
                    }else if(data==-4){
                        setHtml(o,"系统配置文件出错，请与高级管理员联系\uff01");
                    } else if(data==-3){
                        setHtml(o,"用户名或密码含有SQL注入字符串，禁止登陆\uff01");
                        document.manage.username.value="";
                        document.manage.password.value="";
                        document.manage.username.focus();
                    } else if(data==-2){
                        if(username.toLowerCase()=="root"){
                            setHtml(o,"您被锁定，请与操作系统管理员联系，需要手动解锁\uff01");
                        }
                        else{
                            setHtml(o,"您被锁定，需要解锁，请与高级管理员联系\uff01");
                        }
                    } else if(data==-1){
                        setHtml(o,"用户名与密码不匹配\uff01");
                        document.manage.password.value="";
                        document.manage.password.focus();
                    } else if(data==0){
                        setHtml(o,"用户名不存在\uff01");
                        document.manage.username.value="";
                        document.manage.password.value="";
                        document.manage.username.focus();
                    } else if(data==1){
                        window.location.href="index.html";
                    } else if(data==-100){
                        setHtml(o,"“"+username+"”已经登陆\uff01");
                        document.manage.username.value="";
                        document.manage.password.value="";
                        document.manage.username.focus();
                    } else{
                        setHtml(o,"未知错误\uff01");
                    }
                });
        }
    }
}
